package com.kjsdfgk.hjmdsf.member.mvp.ui.activity;

import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.blankj.utilcode.util.TimeUtils;
import com.jess.arms.base.BaseActivity;
import com.jess.arms.di.component.AppComponent;
import com.jess.arms.utils.ArmsUtils;
import com.kjsdfgk.hjmdsf.app.entity.Account;
import com.lksdkjs.live.R;
import com.kjsdfgk.hjmdsf.member.di.component.DaggerMemberCenterComponent;
import com.kjsdfgk.hjmdsf.member.mvp.contract.MemberCenterContract;
import com.kjsdfgk.hjmdsf.member.mvp.presenter.MemberCenterPresenter;


import java.io.UnsupportedEncodingException;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.TreeMap;

import butterknife.BindView;
import butterknife.OnClick;
import cn.leancloud.AVUser;

import static com.jess.arms.utils.Preconditions.checkNotNull;


/**
 * ================================================
 * Description:
 * <p>
 * Created by MVPArmsTemplate on 04/15/2020 11:11
 * <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
 * <a href="https://github.com/JessYanCoding">Follow me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms">Star me</a>
 * <a href="https://github.com/JessYanCoding/MVPArms/wiki">See me</a>
 * <a href="https://github.com/JessYanCoding/MVPArmsTemplate">模版请保持更新</a>
 * ================================================
 */
public class MemberCenterActivity extends BaseActivity<MemberCenterPresenter> implements MemberCenterContract.View {

    @Override
    public void setupActivityComponent(@NonNull AppComponent appComponent) {
        DaggerMemberCenterComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .view(this)
                .build()
                .inject(this);
    }

    @Override
    public int initView(@Nullable Bundle savedInstanceState) {
        return R.layout.activity_member_center; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
    }
    @BindView(R.id.tv_user_name)
    TextView tv_user_name;
    @BindView(R.id.tv_user_expire_time)
    TextView expire_time;
    @Override
    public void initData(@Nullable Bundle savedInstanceState) {
            AVUser avUser = AVUser.getCurrentUser();
        Account account = mPresenter.getAccount();
        mPresenter.getGoods();
            if (account!=null){
                tv_user_name.setText("用    户："+account.getName());
                expire_time.setText("到    期："+TimeUtils.millis2String(Long.parseLong(account.getVip())*1000) );
            }
    }

    @Override
    public void showLoading(String key) {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public boolean isCancel() {
        return false;
    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        ArmsUtils.snackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        ArmsUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }

    @OnClick({R.id.member_center_v1_cv, R.id.member_center_v2_cv, R.id.member_center_v3_cv, R.id.member_center_v4_cv})
    public void onViewClicked(View view) {
        mPresenter.payMemBer(view.getId());

    }
    @Override
    public void showPayDlg() {
        final BottomDialog dialog = BottomDialog.newInstance();
        dialog.show(getFragmentManager(), "pay_dialog");
        dialog.setListener(new BottomDialog.OnPayListener() {
            @Override
            public void click(String payType) {
                dialog.dismiss();
                mPresenter.goAppToPay(payType);
            }
        });
    }

    @Override
    public void showGoodsList(String toString) {

    }


}
